package HuaWeiPractice;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Test_Date_20210426 {
    public static void main(String[] args) {
        //SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH24:mm:ss");
        /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.DATE, -1);
        Date today1 = c.getTime();
        String today_1 = sdf.format(today1);
        String todayq1=today_1+" 00:00:00";
        System.out.println("today_1:"+todayq1);

        Calendar c1 = Calendar.getInstance();
        c1.setTime(new Date());
        c1.add(Calendar.DATE, 0);
        Date today = c1.getTime();
        String todayf = sdf.format(today);
        String today_now=todayf+" 00:00:00";
        System.out.println("today_now:"+today_now);*/

        /*SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.DATE, -1);
        Date today1 = c.getTime();
        String today_1 = sdf.format(today1);
        System.out.println(today_1);

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar c1 = Calendar.getInstance();
        c.setTime(new Date());
        Date now = c1.getTime();
        String now1 = sdf2.format(now);
        System.out.println(now1);*/

        /*SimpleDateFormat sdfr = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdfy = new SimpleDateFormat("yyyyMM");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.DATE, 0);
        Date today1 = c.getTime();
        String today = sdfr.format(today1);
        String today_Month = sdfy.format(today1);
        System.out.println(today_Month);
        System.out.println(today);*/

        /*SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.MONTH, -1);
        Date month1 = c.getTime();
        String month_1 = sdf.format(month1);//取当前日上月
        System.out.println(month_1);
        Calendar c1 = Calendar.getInstance();
        c1.setTime(new Date());
        c1.add(Calendar.MONTH, -2);
        Date month2 = c1.getTime();
        String month_2 = sdf.format(month2);//取当前日上上月
        System.out.println(month_2);*/

        /*SimpleDateFormat sdf3 = new SimpleDateFormat("dd");
        Calendar c3 = Calendar.getInstance();
        c3.setTime(new Date());
        c3.add(Calendar.DATE, 0);
        Date day = c3.getTime();
        String dayCount = sdf3.format(day);//取当前日上月
        String a = "01,02,03,04,05,06,07,08,09";
        if (a.contains(dayCount)) {
            dayCount = dayCount.substring(1, 2);
        }
        System.out.println(dayCount);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.DATE, -1);
        Date today1 = c.getTime();
        String today_1 = sdf.format(today1);//取当前时间昨日
        System.out.println(today_1);*/

        /*SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c1 = Calendar.getInstance();
        c1.setTime(new Date());
        Date now = c1.getTime();
        String today = sdf2.format(now)+" 00:00:00";
        System.out.println(today);
        //20210508160319759dkxjh50000153595463*/
        /*SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        Calendar m = Calendar.getInstance();
        m.setTime(new Date());
        m.add(Calendar.MONTH, 0);
        Date m_0 = m.getTime();
        String m0 = sdf.format(m_0);
        System.out.println(m0);

        Calendar m1 = Calendar.getInstance();
        m1.setTime(new Date());
        m1.add(Calendar.MONTH, -1);
        Date m_1 = m1.getTime();
        String ml1 = sdf.format(m_1);
        System.out.println(ml1);

        Calendar m2 = Calendar.getInstance();
        m2.setTime(new Date());
        m2.add(Calendar.MONTH, -2);
        Date m_2 = m2.getTime();
        String ml2 = sdf.format(m_2);
        System.out.println(ml2);*/

        SimpleDateFormat sdf5 = new SimpleDateFormat("yyyy-MM");
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.MONTH, 0);
        int month_Count = c.getActualMaximum(Calendar.DAY_OF_MONTH);
        Date m10 = c.getTime();
        String mon = sdf5.format(m10);
        System.out.println(mon);
        System.out.println(month_Count);


    }
}
